if (buffer.isNewFile() && buffer.getPath() != null)
{
// Only look further if the mode is 'java', or still the default
String buffer_mode = buffer.getMode().toString();
if (buffer_mode.equals("java") || buffer_mode.equals(jEdit.getProperty("buffer.defaultMode","")))
{
String fullpath = buffer.getPath();
VFS vfs = VFSManager.getVFSForPath(fullpath);
// Split into constituent parts
String path = vfs.getParentOfPath(fullpath);
String name = vfs.getFileName(fullpath);
// At most, check the first 250 lines - this sounds reasonable to me
int maxLine = Math.min(buffer.getLineCount(),250);
import gnu.regexp.RE;
import gnu.regexp.REMatch;
// Build the regex - based on the offical java language spec.
RE regex = new RE("^\\s*(public|protected|private|static|abstract|final|native|synchronized|transient|volatile|strictfp)?\\s*(class|interface)\\s*([^ {/]*)");
int regexMinimum = regex.getMinimumLength();
boolean inComment = false;
for(int i=0;i<maxLine;i++)
{
String txt = buffer.getLineText(i);
int count = 0;
// See if this line has a the start or finish of a multiline comment
while (txt.indexOf("/*")!=-1 || txt.indexOf("*/")!=-1)